<?php include('_init_.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/admin-body.css" rel="stylesheet" type="text/css" />
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
<link href="../css/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript" src="../js/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
// <![CDATA[
$(function(){
	$(".uploadifyupload").each(function(){
		
		var previous_img_id = $(this).attr('name');
		$(this).uploadify({
			'uploader': 'uploadify.swf',
			'cancelImg': 'cancel.png',
			'script': 'uploadify.php',
			'folder': 'files',
			'multi': false,
			'fileExt':'*.jpg;*.jpeg;*.gif;*.png',
				'fileDesc':'Image Files',
			'auto': true,
			'scriptData':{'<?php echo session_name();?>':'<?php echo session_id();?>','name':$(this).attr('name'),'responsetype':'sizeinfo'},
			'displayData': 'speed',
			'onComplete':function(event,queueID,fileObj,response,data){
				var responseObj = eval("("+response+")");
				var fileName = responseObj.name;
				$('#img_'+previous_img_id).attr('src','../img/tmp/' + fileName);
				$('#img_'+previous_img_id).parent().show();
				$('input[name=ajaxf_'+previous_img_id+']').val(fileName);
				
			},
			'onError':function(event,queueId,fileObj,errorObj){
				alert(errorObj);
			}
		});
	});
});
// ]]>
</script>
<title>班尼頓寫真後台管理</title>
</head>

<body>
<?php include_once('admin-top.php');?>
<div id="main" class="clearfix"><!-- star #main //-->
<?php include_once('sub-index.php');?>
  
  
  <div id="contact"><!-- star #contact //-->
    <ul>
    <li class="tit-a">首頁作品<span class="nav_note">size: 190 X 190</span></li>
    
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" name="f_new"> 
    <li class="impotc">
     名稱：<input name="title" type="text" class="impotc-keyina" />
      </li>
      <li class="impotc">
      網址：<input name="url" type="text" class="impotc-keyinb" />
      </li>
      <li class="impota">
        <input id="hot_good_new" type="file" name="hot_good_new" class="uploadifyupload"/> 
         <input name="ajaxf_hot_good_new" type="hidden"/>
      </li>
      <li class="impotb">
      <a href="#" onclick="document.forms['f_new'].submit();return false;">新增 </a></li>
    <li class="maina" style="display:none"><img id="img_hot_good_new" src="" /> </li>      
      <li class="tit-b"></li>
      </form>
      
      <?php foreach($GLOBALS['list_data'] as $row):?>
      <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" name="f_<?php echo $row['id'];?>"> 
      <input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
    <li class="impotc">
     名稱：<input name="title" type="text" class="impotc-keyina" value="<?php echo $row['title'];?>"/>
      </li>
      <li class="impotc">
      網址：<input name="url" type="text" class="impotc-keyinb" value="<?php echo $row['url'];?>"/>
      </li>
      <li class="impota">
        <input id="hot_good_<?php echo $row['id'];?>" type="file" name="hot_good_<?php echo $row['id'];?>" class="uploadifyupload"/> 
         <input name="ajaxf_hot_good_<?php echo $row['id'];?>" type="hidden"/>
      </li>
      <li class="impotb">
      <a href="<?php echo $_SERVER['PHP_SELF']?>?act=del&id=<?php echo $row['id'];?>"  onclick="return confirm('確定刪除?');">刪除</a>
      <a href="#" onclick="document.forms['f_<?php echo $row['id'];?>'].submit();return false;">儲存 </a>
      </li>
    <li class="maina" <?php if( !$row['img']):?>style="display:none"<?php endif;?>><img id="img_hot_good_<?php echo $row['id'];?>" src="../img/<?php echo $GLOBALS['GV_IMAGE_PATH'].$row['img'];?>" /> </li>      
      <li class="tit-b"></li>
      </form>
      <?php endforeach;?>
    </ul>
  </div><!-- end #contact //-->
</div><!-- end #main //-->
</body>
</html>